import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm';
import { Post } from './post.entity';
import { User } from '../../auth/entities/user.entity';

@Entity()
export class Reply {
  @PrimaryGeneratedColumn({
    type: 'int',
    name: 'id',
    comment: '回复ID',
  })
  id: number;

  @Column({
    type: 'text',
    comment: '回复内容',
  })
  content: string;

  @ManyToOne(() => Post, (post) => post.replies)
  post: Post;

  @ManyToOne(() => User)
  author: User;

  @Column({
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
    comment: '创建时间',
  })
  createTime: Date;

  @Column({
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
    onUpdate: 'CURRENT_TIMESTAMP',
    comment: '更新时间',
  })
  updateTime: Date;
}
